package changgou.search.controller;


import changgou.search.service.SkuService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.Map;

@RestController
@RequestMapping(value = "/search")
@CrossOrigin
public class SkuController {

    @Autowired
    private SkuService skuService;

    /*
    * 调用搜索实现
    * */
    @GetMapping
    public Map search(@RequestParam(required = false) Map<String,String> searchMap) throws SQLException {
        return skuService.search(searchMap);
    }


    @GetMapping(value = "/import")
    public Result importData(){
        skuService.importData();
        return new Result(true, StatusCode.OK,"执行操作成功！");
    }
}
